package cn.lingyangwl.agile.misc.statistic;

import cn.lingyangwl.agile.misc.statistic.constant.*;
import cn.lingyangwl.agile.misc.statistic.model.*;
import cn.lingyangwl.agile.misc.statistic.service.*;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author shenguangyang
 */
@Service
@Primary
public class StatisticApiImpl implements StatisticApi {
    @Resource
    private RabbitTemplate rabbitTemplate;
    @Resource
    @Lazy
    private StatAnalyzeService analyzeService;

    @Override
    public void syncTask() {
        analyzeService.syncStatistic();
    }

    @Override
    public void sendMsg(StatisticBaseReq req) {
        rabbitTemplate.convertAndSend(StatisticCons.EXCHANGE, req.getName(), req.toMessage());
    }
}
